<template>
  <div id="curriculum_manage" class="container">
    <div class="content">
      <!-- <div class="title">课程管理</div> -->
      <div class="panel">
        <div class="condition">
          <div class="row_one">
            <el-select
              style="width:12%;float: left;"
              v-model="tabledisplayObj.courseType"
              clearable
              v-if="menu == 2"
              placeholder="课程类别"
            >
              <el-option
                v-for="item in courseTypeList"
                :key="item.value"
                :label="item.name"
                :value="item.value"
              ></el-option>
            </el-select>
            <el-cascader
              style="width:12%;float: left;margin-left:.1rem; "
              v-model="selectSubjectId"
              :options="subjectList"
               :props="{ checkStrictly: true }"
              placeholder="科目"
              clearable
            ></el-cascader>
            <!-- <el-select
              style="width:12%;float: left;margin-left:.1rem; "
              v-model="tabledisplayObj.subjectId"
              clearable
              placeholder="科目"
            >
              <el-option
                v-for="item in subjectList"
                :key="item.subjectId"
                :label="item.name"
                :value="item.subjectId"
              ></el-option>
            </el-select>-->
            <div style="width:2.68rem;float: left;margin-left:.1rem;">
              <el-select
                v-model="tabledisplayObj.startSuitableAge"
                @change="ageStartChange(1)"
                clearable
                style="width: 1.2rem;"
                placeholder="开始年龄"
              >
                <el-option
                  v-for="item in ageStartList"
                  :key="item.value"
                  :label="item.name"
                  :value="item.value"
                  v-show="item.show"
                ></el-option>
              </el-select>&nbsp;~
              <el-select
                v-model="tabledisplayObj.endSuitableAge"
                @change="ageEndChange(1)"
                clearable
                style="width: 1.2rem;"
                placeholder="结束年龄"
              >
                <el-option
                  v-for="item in ageEndList"
                  :key="item.value"
                  :label="item.name"
                  :value="item.value"
                  v-show="item.show"
                ></el-option>
              </el-select>
            </div>
            <el-input
              v-model="tabledisplayObj.courseName"
              style="width:12%;float: left;margin-left:.1rem;"
              placeholder="输入课程名称"
              class="input_search"
              clearable
            ></el-input>
            <div
              v-if="menu == 2 && hasApi('courseAdd')"
              class="right_btn"
              @click="createCampus"
            >新&nbsp&nbsp增</div>
            <div
              v-else-if="menu == 1 && hasApi('deploySetting')"
              @click="openDoubleTeacherSet"
              class="btn_user_defined"
              style="margin-right:0.1rem;float: right;width:1.9rem;"
            >双师收费标准设置</div>
            <div
              v-if="menu == 1 && hasApi('libraryCourseList')"
              @click="searchCourse()"
              class="search_btn"
              style="margin-left:0.1rem;"
            >搜索</div>
            <div
              v-else-if="menu == 2 && hasApi('courseListByPage')"
              @click="searchCourse()"
              class="search_btn"
              style="margin-left:0.1rem;"
            >搜索</div>
            <div
              v-if="menu == 1 && hasApi('libraryCourseList')"
              @click="resetCourse()"
              class="btn_user_defined"
              style="margin-left:0.1rem;"
            >重置</div>
            <div
              v-if="menu == 2 && hasApi('courseListByPage')"
              @click="resetCourse()"
              class="btn_user_defined"
              style="margin-left:0.1rem;"
            >重置</div>
            <!--  -->
          </div>
        </div>
        <!--列表-->
        <div v-if="menu == 1">
          <table class="table" cellspacing="0">
            <thead class="thead">
              <tr>
                <td style="width: 4rem;">课程名称</td>
                <td style="width: 2rem;">科目</td>
                <td style="width: 2rem;">时长(分钟/节)</td>
                <td style="width: 1.5rem;">课节数(节)</td>
                <td style="width: 1.5rem;">开课校区</td>
                <td style="width: 1.5rem;">开班数</td>
                <td style="width: 1.5rem;">学员人数(人)</td>
                <td style="width: 1.5rem;">状态</td>
                <td style="width: 3rem;">上架时间</td>
                <td style="width: 1.5rem;">操作</td>
              </tr>
            </thead>
            <tbody class="tbody">
              <tr v-for="item,index in courseList">
                <td>{{item.libraryCourseName}}</td>
                <td v-if="item.subSubjectName == null">{{item.subjectName}}</td>
                <td v-else>{{item.subjectName}} / {{item.subSubjectName}}</td>
                <td>{{item.oneSyllabusDuration}}</td>
                <td>{{item.syllabusNum}}</td>
                <td>
                  <div
                    :class="{line:item.status == 2}"
                    @click="clickCampus(item)"
                  >{{item.campusIds.length}}</div>
                </td>
                <td>{{item.status == 1?'-':item.openingClassCount}}</td>
                <td>{{item.status == 1?'-':item.enrollment}}</td>
                <td>{{item.status == 1?"待上架":"上架中"}}</td>
                <td>{{item.rackingTime == null?"":item.rackingTime}}</td>
                <td>
                  <span
                    v-if="hasApi('toggleRunningStatus')"
                    class="operate_btn"
                    @click="handleUp(index,item)"
                  >{{item.status == 1?"上架":"下架"}}&nbsp;</span>
                </td>
              </tr>
            </tbody>
          </table>
        </div>
        <!--列表-->
        <div v-else>
          <table class="table" cellspacing="0">
            <thead class="thead">
              <tr>
                <td style="width: 3rem;">课程名称</td>
                <td style="width: 2rem;">适用年龄</td>
                <td style="width: 2rem;">科目</td>
                <td style="width: 2rem;">课程类型</td>
                <td style="width: 2rem;">课程总数(节/天)</td>
                <td style="width: 1.2rem;">收费模式</td>
                <td style="width: 3rem;">校区售价(元)</td>
                <td style="width: 1rem;">课件授权班级数</td>
                <td style="width: 1rem;">开班数</td>
                <td style="width: 1rem;">状态</td>
                <td style="width: 3rem;">新增时间</td>
                <td style="width: 3rem;">操作</td>
              </tr>
            </thead>
            <tbody class="tbody">
              <tr v-for="item,index in courseList">
                <td>
                  <div style="display: flex;justify-content: center;align-items: center;">
                    <div v-if="item.courseAttributeType == 1" class="name_img_org"></div>
                    <div v-else-if="item.courseAttributeType == 2" class="name_img_sch"></div>
                    <div v-else class="name_img_blend"></div>
                    <div style="margin-left:0.05rem">{{item.courseName}}</div>
                  </div>
                </td>
                <td v-if="item.minSuitableAge != null">
                  {{item.minSuitableAge}}岁~{{item.maxSuitableAge}}岁
                  <i
                    v-if="item.courseAttributeType == 2"
                    class="el-icon-edit nameEdit"
                    @click="ageChange(item)"
                  ></i>
                </td>
                <td v-else>
                  <i
                    v-if="item.courseAttributeType == 2"
                    class="el-icon-edit nameEdit"
                    @click="ageChange(item)"
                  ></i>
                </td>
                <td v-if="item.subSubjectName == null">{{item.subjectName}}</td>
                <td v-else>{{item.subjectName}} / {{item.subSubjectName}}</td>
                <td>{{item.courseTypeName}}</td>
                <td style="max-width:1.5rem;word-wrap: break-word;">{{item.periodNumList}}{{item.periodUnit}}</td>
                <td>{{item.chargeModeName}}</td>
                <td style="max-width:2rem;word-wrap: break-word;">{{item.priceList}}</td>
                <td v-if="item.authorizeClassTotalOfCourse !=0"><div class="line" @click="showAuthList(item.libraryCourseCampusList)">{{item.authorizeClassTotalOfCourse}}</div></td>
                <td v-else>{{item.authorizeClassTotalOfCourse}}</td>
                <td>{{item.classNumber}}</td>
                <td>{{item.isOpeningClass == 0 ?'未开班':"已开班"}}</td>
                <td>{{item.createTime}}</td>
                <td>
                  <span
                    v-if="hasApi('courseUpdate')"
                    class="operate_btn"
                    @click="handleUpdate(index,item)"
                  >编辑&nbsp;</span>
                  <span
                    v-if="item.courseAttributeType !=2 && hasApi('librarySyllabusList')"
                    class="operate_btn"
                    @click="handleLook(index,item)"
                  >课件查看&nbsp;</span>
                  <span
                    v-if="item.courseAttributeType ==2 && hasApi('librarySyllabusList')"
                    class="operate_btn"
                    @click="handleEdit(index,item)"
                  >资源配置&nbsp;</span>
                  <span
                    v-if="item.deletableOfCourse && hasApi('courseDetele')"
                    class="operate_btn"
                    @click="handleDelete(index,item)"
                  >删除</span>
                </td>
              </tr>
            </tbody>
          </table>
        </div>
        <el-pagination
          class="page"
          layout="total, sizes, prev, pager, next, jumper"
          :current-page="tabledisplayObj.currPage"
          @size-change="pageSizeChange"
          @current-change="tabledisplayChangePage"
          :total="tabledisplayObj.total"
        ></el-pagination>
        <!--选择校区-->
        <selectCampus ref="selectCampus" @callback="closeAdd"></selectCampus>
        <!--新建课程-->
        <createCampusCourse ref="createCampusCourse" @callback="closeAdd"></createCampusCourse>
        <sylllabusList ref="sylllabusList" @callback="closeAdd"></sylllabusList>
      </div>
    </div>
    <el-dialog
      title="双师收费标准设置"
      :visible.sync="dialogFormVisible_update"
      center
      width="40%"
      :close-on-click-modal="false"
    >
      <el-form>
        <div v-for="item in teacherCourseSetList" :key="item.foreignTeacherTypeName">
          <el-form-item :label="item.foreignTeacherTypeName" label-width="240px" :rules="[]">
            <el-input
              style="width:60%"
              maxlength="9"
              clearable
              v-model="item.oneSyllabusPrice"
              placeholder="请输入价格"
              onkeypress="return(/[\d]/.test(String.fromCharCode(event.keyCode)))"
              oninput="value=value.replace(/[^\d]/g,'')"
            >
              <template slot="append">元/节课</template>
            </el-input>
          </el-form-item>
        </div>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="sureSetting()">确定设置</el-button>
      </div>
    </el-dialog>
    <el-dialog
      title="编辑适用年龄"
      :visible.sync="dialogFormVisible_age"
      center
      width="25%"
      :close-on-click-modal="false"
    >
      <div style="margin-left:1rem;">
        <el-select
          v-model="ageSetObject.minSuitableAge"
          @change="ageStartChange(2)"
          clearable
          style="width: 1.2rem;"
          placeholder="开始年龄"
          @before-close="cancel()"
        >
          <el-option
            v-for="item in ageStartList"
            :key="item.value"
            :label="item.name"
            :value="item.value"
            v-show="item.show"
          ></el-option>
        </el-select>&nbsp;~
        <el-select
          v-model="ageSetObject.maxSuitableAge"
          @change="ageEndChange(2)"
          clearable
          style="width: 1.2rem;"
          placeholder="结束年龄"
        >
          <el-option
            v-for="item in ageEndList"
            :key="item.value"
            :label="item.name"
            :value="item.value"
            v-show="item.show"
          ></el-option>
        </el-select>
      </div>
      <div slot="footer" class="dialog-footer">
        <el-button type="primary" @click="settingAge()">确定</el-button>
      </div>
    </el-dialog>
    <el-dialog
      :title="course_title"
      :visible.sync="dialogFormVisible_course"
      width="30%"
      :close-on-click-modal="false"
    >
      <div class="row_one" style="padding: 0.1rem 0 0.1rem 0;">
        <el-input
          v-model="searchCourseLibrary"
          style="width:40%;float: left;margin-left:.1rem;"
          placeholder="输入库课程名称"
          class="input_search"
        ></el-input>
        <div @click="searchCourseName()" class="search_btn" style="margin-left:0.1rem;">搜索</div>
      </div>
      <div>
        <table
          class="table"
          cellspacing="0"
          style="width:100%;margin-bottom:0.3rem;margin-top:0.2rem;"
        >
          <tbody class="tbody">
            <tr v-for="item,index in courseListByFull" style="cursor: pointer;">
              <td @click="gotoSyllabus(item)">{{item.libraryCourseName}}</td>
            </tr>
          </tbody>
        </table>
      </div>
    </el-dialog>
    <el-dialog
      title="课件授权详情"
      :visible.sync="dialogFormVisible_auth"
      width="30%"
      :close-on-click-modal="false"
    >
      
      <div>
        <table
          class="table"
          cellspacing="0"
          style="width:100%;margin-bottom:0.3rem;margin-top:0.2rem;"
        >
            <thead class="thead">
              <tr>
                <td style="width: 3rem;">课程名称</td>
                <td style="width: 3rem;">授权班级个数</td>
                <td style="width: 3rem;">使用班级个数</td>
              </tr>
            </thead>
          <tbody class="tbody">
            <tr v-for="item,index in authList">
              <td >{{item.libraryCourseName}}</td>
              <td >{{item.authorizeClassAmount}}</td>
              <td >{{item.authorizeClassAmount-item.availableAuthorizeClassAmount}}</td>
            </tr>
          </tbody>
        </table>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { mapState, mapGetters, mapActions } from "vuex"; //先要引入
import createCampusCourse from "./common/createCampusCourse";
import selectCampus from "./common/selectCampus";
import sylllabusList from "./common/sylllabus_list";
let vm;
let user;
export default {
  components: {
    createCampusCourse,
    selectCampus,
    sylllabusList
  },
  data() {
    return {
      menu: 1,
      searchCourseLibrary: "", //全日制库课程筛选
      course_title: "", //全日制课程名称
      dialogFormVisible_course: false, //全日制库课程数据显示/隐藏
      dialogFormVisible_update: false, //双师价格设置显示/隐藏
      dialogFormVisible_auth:false,//授权显示/隐藏
      authList:[],
      copyCourseListByFull: [], //复制全日制库课程数据
      courseListByFull: [], //全日制库课程数据
      isLook: true, //是否查看资源/配置资源
      teacherCourseSetList: [], //双师教师数据
      selectSubjectId: [], //筛选科目的数组
      componentname: "",
      dialogFormVisible_age: false,
      ageSetObject: {
        courseId: "",
        minSuitableAge: "",
        maxSuitableAge: ""
      },
      tabledisplayObj: {
        isPublished: 1,
        courseType: "", //课程类型
        subjectId: "", //科目
        startSuitableAge: "", //适用年龄
        endSuitableAge: "",
        courseName: "", //课程名
        currPage: 1,
        orgId: "",
        pageSize: 10,
        total: 0
      },
      ageStartList: [], //筛选适用年龄数据
      ageEndList: [], //筛选适用年龄数据
      courseTypeList: [], //课程类型数组
      subjectList: [], //科目数组
      courseList: [],
      chargeModeList: []
    };
  },
  methods: {
    /**显示授权数据 */
    showAuthList(listData){
      vm.authList = listData;
      vm.dialogFormVisible_auth = true;
    },
    cancel() {
      vm.ageSetObject = {
        courseId: "",
        minSuitableAge: "",
        maxSuitableAge: ""
      };
      vm.ageStartChange(2);
      vm.ageStartChange(2);
    },
    ageChange(item) {
      vm.dialogFormVisible_age = true;
      console.log(item)
      vm.ageSetObject = {
        courseId: item.courseId,
        minSuitableAge: item.minSuitableAge == null ? "0" : item.minSuitableAge,
        maxSuitableAge: item.maxSuitableAge == null ? "0" : item.maxSuitableAge
      };
    },
    settingAge() {
      console.log(vm.ageSetObject)
      api.updateSuitableAge(vm.ageSetObject).then(function(data) {
        if (data.resultCode == 2000) {
          vm.$message({
            message: "编辑成功",
            type: "success"
          });
          vm.dialogFormVisible_age = false;
          vm.ageSetObject = {
            courseId: "",
            minSuitableAge: "",
            maxSuitableAge: ""
          };
          vm.ageStartChange(2);
          vm.ageStartChange(2);
          vm.initData();
        } else {
          vm.$message.error(data.message);
        }
      });
    },
    openDoubleTeacherSet() {
      api.getTeacherCourseSetList().then(function(data) {
        if (data.resultCode == 2000) {
          if (data.list.length == 0) {
            vm.teacherCourseSetList = [
              {
                foreignTeacherTypeName: "菲律宾老师",
                foreignTeacherType: 1,
                oneSyllabusPrice: ""
              },
              {
                foreignTeacherTypeName: "欧美老师",
                foreignTeacherType: 2,
                oneSyllabusPrice: ""
              }
            ];
          } else {
            vm.teacherCourseSetList = data.list;
          }
          vm.dialogFormVisible_update = true;
        } else {
          vm.$message.error(data.message);
        }
      });
    },
    campusChange: function(campusId) {
      vm.tabledisplayObj = {
        isPublished: 1,
        courseType: "", //课程类型
        subjectId: "", //科目
        startSuitableAge: "", //适用年龄
        endSuitableAge: "",
        courseName: "", //课程名
        currPage: 1,
        orgId: "",
        pageSize: 10,
        total: 0
      };
      vm.selectSubjectId = [];
      vm.initData();
    },
    /**
     * 初始化数据
     */
    initData() {
      vm.tabledisplayObj.orgId = user.orgId;
      if (vm.menu == 1) {
        api.libraryCourseList(vm.tabledisplayObj).then(function(data) {
          if (data.resultCode == 2000) {
            for (let i = 0; i < data.list.length; i++) {
              data.list[i].createTime = data.list[i].createTime.split(" ")[0];
            }
            vm.courseList = data.list;
            vm.tabledisplayObj.total = data.totalCount;
          } else {
            vm.$message.error(data.message);
          }
        });
      } else {
        let paras = vm.tabledisplayObj;
        paras.campusId = this.$store.state.campusId;
        let courselisttemp = [];
        api.courseListByPage(paras).then(function(data) {
          if (data.result == "操作成功") {
            courselisttemp = data.list;
            for (let i = 0; i < courselisttemp.length; i++) {
              vm.courseTypeList.forEach(item => {
                if (item.value == courselisttemp[i].courseType) {
                  courselisttemp[i].courseTypeName = item.name;
                }
              });
              for (let b = 0; b < vm.chargeModeList.length; b++) {
                if (
                  vm.chargeModeList[b].value == courselisttemp[i].chargeMode
                ) {
                  courselisttemp[i].chargeModeName = vm.chargeModeList[b].name;
                }
              }
            }
            vm.courseList = courselisttemp;
            console.log(vm.courseList);
            vm.tabledisplayObj.total = data.totalCount;
          }
        });
      }
    },
    ageStartChange: function(type) {
      //开始年龄发生改变
      //限制结束年龄
      vm.ageEndList.forEach(function(item) {
        if (type == 1) {
          if (
            !vm.tabledisplayObj.startSuitableAge ||
            parseInt(item.value) >=
              parseInt(vm.tabledisplayObj.startSuitableAge)
          ) {
            item.show = true;
          } else {
            item.show = false;
          }
        } else {
          if (
            !vm.ageSetObject.minSuitableAge ||
            parseInt(item.value) >= parseInt(vm.ageSetObject.minSuitableAge)
          ) {
            item.show = true;
          } else {
            item.show = false;
          }
        }
      });

      // var age = (vm.ageStart || -1) + "/" + (vm.ageEnd || -1);
    },
    ageEndChange: function(type) {
      //结束年龄发生改变
      //限制开始年龄

      vm.ageStartList.forEach(function(item) {
        if (type == 1) {
          if (
            !vm.tabledisplayObj.endSuitableAge ||
            parseInt(item.value) <= parseInt(vm.tabledisplayObj.endSuitableAge)
          ) {
            item.show = true;
          } else {
            item.show = false;
          }
        } else {
          if (
            !vm.ageSetObject.maxSuitableAge ||
            parseInt(item.value) <= parseInt(vm.ageSetObject.maxSuitableAge)
          ) {
            item.show = true;
          } else {
            item.show = false;
          }
        }
      });

      // var age = (vm.ageStart || -1) + "/" + (vm.ageEnd || -1);
    },
    pageSizeChange: function(val) {
      //页条数发生改变
      this.tabledisplayObj.pageSize = val;
      vm.initData();
    },
    /**表格显示形式翻页 */
    tabledisplayChangePage(val) {
      this.tabledisplayObj.currPage = val;
      vm.initData();
    },
    /**
     * 筛选
     */
    searchCourse() {
      this.tabledisplayObj.currPage = 1;
      if (vm.selectSubjectId.length == 1) {
        vm.tabledisplayObj.subjectId = vm.selectSubjectId[0];
        vm.tabledisplayObj.subSubjectId ="";
      } else if (vm.selectSubjectId.length == 2) {
        vm.tabledisplayObj.subjectId = vm.selectSubjectId[0];
        vm.tabledisplayObj.subSubjectId = vm.selectSubjectId[1];
      } else {
        vm.tabledisplayObj.subjectId = "";
        vm.tabledisplayObj.subSubjectId = "";
      }
      vm.initData();
    },
    /**
     * 重置
     */
    resetCourse() {
      vm.tabledisplayObj = {
        isPublished: 1,
        courseType: "", //课程类型
        subjectId: "", //科目
        startSuitableAge: "", //适用年龄
        endSuitableAge: "",
        courseName: "", //课程名
        currPage: 1,
        orgId: "",
        pageSize: 10,
        total: 0
      };
      vm.selectSubjectId = [];
      this.initData();
    },
    /**资源配置 */
    handleEdit(index, row) {
      if (row.courseType == 2) {
        vm.isLook = false;
        vm.courseListByFull = [];
        vm.copyCourseListByFull = [];
        vm.course_title = row.courseName;
        row.libraryCourseList.forEach(item => {
          vm.courseListByFull.push(item);
        });
        vm.copyCourseListByFull = vm.courseListByFull;
        vm.dialogFormVisible_course = true;
      } else {
        var path = vm.$store.state.permit["56"].path;
        //传递参数
        this.$router.push({
          path: path,
          query: {
            libraryCourseId: row.libraryCourseList[0].libraryCourseId,
            courseTypeId: row.courseType,
            title: row.libraryCourseList[0].libraryCourseName,
            isFrom: false,
            currPage:1
          }
        });
      }
    },
    /**
     * 删除课程
     */
    handleDelete(index, row) {
      this.$confirm("此操作将删除该课程, 是否继续?", "温馨提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
        center: true
      })
        .then(() => {
          let paras = {
            courseId: row.courseId
          };
          api.courseDetele(paras).then(function(data) {
            if (data.result == "操作成功") {
              vm.initData();
              vm.$message({
                message: "删除成功",
                type: "success"
              });
            } else {
              vm.$message.error(data.result);
            }
          });
        })
        .catch(() => {});
    },
    /**选择校区 */
    clickCampus(item) {
      if (item.status == 2) {
        let paras = {
          libraryCourseId: item.libraryCourseId,
          campusIds: tool.clone(item.campusIds)
        };
        this.$refs.selectCampus.init(paras);
      }
    },
    /**创建课程 */
    createCampus() {
      this.$refs.createCampusCourse.init({});
    },
    searchCourseName() {
      if (vm.searchCourseLibrary == "") {
        vm.courseListByFull = vm.copyCourseListByFull;
      } else {
        vm.courseListByFull = vm.copyCourseListByFull.filter(item => {
          return item.libraryCourseName.indexOf(vm.searchCourseLibrary) != -1;
        });
      }
    },
    gotoSyllabus(item) {
      vm.dialogFormVisible_course = false;
      console.log(item);
      if (vm.isLook) {
        this.$refs.sylllabusList.init({
          title: item.libraryCourseName,
          libraryCourseId: item.libraryCourseId,
          courseId: item.courseId,
          courseType:item.courseType
        });
      } else {
        var path = vm.$store.state.permit["56"].path;
        //传递参数
        this.$router.push({
          path: path,
          query: {
            libraryCourseId: item.libraryCourseId,
            courseTypeId: item.courseType,
            title: item.libraryCourseName,
            isFrom: false
          }
        });
      }
    },
    /**课件查看 */
    handleLook(index, item) {
      if (item.courseType == 2) {
        vm.isLook = true;
        vm.courseListByFull = [];
        vm.copyCourseListByFull = [];
        vm.course_title = item.courseName;
        item.libraryCourseList.forEach(item => {
          vm.courseListByFull.push(item);
        });
        vm.copyCourseListByFull = vm.courseListByFull;
        vm.dialogFormVisible_course = true;
      } else {
        this.$refs.sylllabusList.init({
          title: item.libraryCourseList[0].libraryCourseName,
          libraryCourseId: item.libraryCourseList[0].libraryCourseId,
          courseId: item.courseId,
          courseType:item.courseType
        });
      }
    },
    /**修改 课程 */
    handleUpdate(index, item) {
      this.$refs.createCampusCourse.init(tool.clone(item));
    },
    handleUp(index, item) {
      if (item.status == 1) {
        let paras = {
          libraryCourseId: item.libraryCourseId,
          campusIds: []
        };
        this.$refs.selectCampus.init(paras);
      } else {
        this.$confirm("确定下架课程吗？", "课程下架", {
          confirmButtonText: "确定",
          cancelButtonText: "再想想",
          type: "warning",
          center: true
        })
          .then(() => {
            var paras = {
              libraryCourseId: item.libraryCourseId,
              status: 1
            };
            api.toggleRunningStatus(paras).then(function(data) {
              console.log(data);
              if (data.resultCode == 2000) {
                vm.$message({
                  message: "下架课程成功",
                  type: "success"
                });
                vm.initData();
              } else {
                vm.$confirm(data.message, "无法下架", {
                  confirmButtonText: "确定",
                  cancelButtonText: "取消",
                  type: "warning",
                  center: true
                })
                  .then(() => {})
                  .catch(() => {});
              }
            });
          })
          .catch(() => {});
      }
    },
    closeAdd() {
      vm.initData();
    },
    //双师收费确认
    sureSetting() {
      if (vm.teacherCourseSetList[0].oneSyllabusPrice == "") {
        vm.$message({
          message:
            "请输入" +
            vm.teacherCourseSetList[0].foreignTeacherTypeName +
            "的价格",
          type: "warning"
        });
        return;
      }
      if (vm.teacherCourseSetList[1].oneSyllabusPrice == "") {
        vm.$message({
          message:
            "请输入" +
            vm.teacherCourseSetList[1].foreignTeacherTypeName +
            "的价格",
          type: "warning"
        });
        return;
      }
      api.deploySetting(vm.teacherCourseSetList).then(function(data) {
        if (data.result == "操作成功") {
          vm.$message({
            message: "设置成功",
            type: "success"
          });
          vm.dialogFormVisible_update = false;
        } else {
          this.$message.error(data.message);
        }
      });
    }
  },
  mounted() {
    vm = this;
    user = tool.getItem(lsKey.user, true); //得到当前用户信息
    vm.menu = user.roleMode <= 1 ? 1 : 2;
    //获取数据字典
    let dicdata = tool.getItem(lsKey.dict, true);
    this.courseTypeList = [];
    this.subjectList = [];
    this.courseTypeList = dicdata["course_type"];
    this.chargeModeList = dicdata["charge_mode"]; //课程收费模式数据字典
    for (let i = 0; i < 100; i++) {
      vm.ageStartList.push({ name: "" + i, value: "" + i, show: true });
      vm.ageEndList.push({ name: "" + i, value: "" + i, show: true });
    }
    api
      .getSubjectList({
        orgId: user.orgId + ""
      })
      .then(function(data) {
        //枚举科目列表
        if (data.result == "操作成功") {
          data.list.forEach(item => {
            let subList = [];
            item.subSubjectList.forEach(r => {
              subList.push({
                value: r.subSubjectId,
                label: r.subSubjectName
              });
            });
            if (subList.length > 0) {
              vm.subjectList.push({
                value: item.subjectId,
                label: item.name,
                children: subList
              });
            } else {
              vm.subjectList.push({
                value: item.subjectId,
                label: item.name
              });
            }
          });
        } else {
          this.$message.error(data.message);
        }
      });
    this.initData();
  },
  computed: {}
};
</script>

<style lang="scss">
#curriculum_manage {
  .el-input__inner {
    border-radius: 0.08rem;
    font-size: 0.16rem;
    color: #666666;
    height: 0.36rem;
    line-height: 0.36rem;
  }
  .el-form-item__label {
    font-size: 0.16rem;
    color: #666666;
  }
  .el-input__icon {
    line-height: 0.36rem;
  }
  .el-dialog__body {
    padding: 0.1rem 0.2rem;
    color: #606266;
    font-size: 0.14rem;
  }
  .nameEdit {
    cursor: pointer;
  }
  .el-dialog__title {
    line-height: 0.24rem;
    font-size: 0.2rem;
    color: #333333;
  }
  .el-input-group__append,
  .el-input-group__prepend {
    background-color: #ffffff;
    color: #666666;
    border: 0rem solid #ffffff;
    font-size: 0.16rem;
    padding: 0 0.1rem;
  }

  .input_search {
    .el-input__inner {
      background-color: rgb(247, 248, 250);
    }
  }
  .right_btn {
    background-image: url(../../assets/img/clue_manage/add_white.png);
    width: 1.54rem;
  }
  .name_img_org {
    margin-right: 0.04rem;
    width: 0.42rem;
    height: 0.26rem;
    background-image: url(../../assets/img/common/mechanism.png);
  }
  .name_img_sch {
    margin-right: 0.04rem;
    width: 0.42rem;
    height: 0.26rem;
    background-image: url(../../assets/img/common/support.png);
  }
  .name_img_blend {
    margin-right: 0.04rem;
    width: 0.42rem;
    height: 0.26rem;
    background-image: url(../../assets/img/common/blend.png);
  }
  .line {
    text-decoration: underline;
    cursor: pointer;
    color: #3885f8;
  }
  .btn_user_defined {
    display: inline-block;
    width: 0.8rem;
    padding-left: 0.22rem;
    height: 0.36rem;
    line-height: 0.36rem;
    border-radius: 0.08rem;
    color: white;
    font-size: 0.16rem;
    cursor: pointer;
    letter-spacing: 0.03rem;
    background-color: #3885f8;
    position: relative;
    top: 0.01rem;
  }
  .btn_user_defined:hover {
    background-color: rgba(56, 133, 248, 0.8);
  }
  .demo-table-expand {
    font-size: 0;
  }
  .demo-table-expand label {
    width: 90px;
    color: #99a9bf;
  }
  .demo-table-expand .el-form-item {
    margin-right: 0;
    margin-bottom: 0;
    width: 45%;
  }
  // .el-table__expand-icon .el-icon-arrow-right:before {
  //   content: "\e603";
  // }
  // .el-table__expand-icon--expanded {
  //   -webkit-transform: rotate(180deg);
  //   transform: rotate(180deg);
  // }
  .btn_editor {
    font-size: 0.16rem;
  }
}
</style>
<style scoped src="@/style/module/table.css"></style>
<style scoped src="@/style/clue_manage/clue_manage.css"></style>
<style scoped>
.title_tab {
  display: flex;
}
.title_item {
  font-size: 0.24rem;
  color: #999999;
  text-shadow: 0.01rem 0 0 currentcolor;
  line-height: 0.6rem;
  cursor: pointer;
}
.title_active {
  color: #141414;
}
</style>